package com.github.blanexie.tserver.http;

import io.netty.channel.ChannelProgressiveFuture;
import io.netty.channel.ChannelProgressiveFutureListener;
import lombok.extern.slf4j.Slf4j;

/**
 * @author xiezc
 * @data 2024/3/13 14:43
 */
@Slf4j
public class HttpChannelProgressiveListener implements ChannelProgressiveFutureListener {
    @Override
    public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) {
        if (total < 0) { // total unknown
            log.warn(future.channel() + " Transfer progress: " + progress);
        } else {
            log.info(future.channel() + " Transfer progress: " + progress + " / " + total);
        }
    }

    @Override
    public void operationComplete(ChannelProgressiveFuture future) {
        log.info(future.channel() + " Transfer complete.");
    }
}